<?php

$_PHPFOX = array();

$oReq = &App::getRequest();
$oTpl = &App::getTemplate();
$oDb = &Database::get();

global $_MSG;
global $_CONF;

$oSecurity = App::getModuleService('Account', 'Security');

$oCache = &App::newObject("Cache");

$oCache->setFile('pages_'. str_replace("-", "_", $sParam) .'.php');

if ( !$oCache->isCached() )
{
	$aPage = $oDb->getRow("SELECT * FROM ". App::getT('pages') ." WHERE title_url = '". $oDb->escape($sParam) ."' LIMIT 1");

	if ( isset($aPage['page_id']) )
	{
		$oCache->save($aPage);
	}
}

$aCachedPage = $oCache->doRequire();

if ( isset($aCachedPage['title_head']) )
{
	App::setPageName('public.'. $sParam .'');

	// Creates the name of the new page
	$_CONF['Mod_Site.page_title.'. $sParam .''] = strip_tags($aCachedPage['title_head']);

	// Creates the connection to the new pages name
	$_CONF['Mod_Site.page_title'][$sParam] = '^public\.'. $sParam .'';

	$_CONF['url.reserved_names'][] = $sParam;
}

$oTpl->assignSrc(array
(
	'sContent' => (isset($aCachedPage['content']) ? $aCachedPage['content'] : ''),
	'sPageKeywords' => (isset($aCachedPage['meta']) ? $aCachedPage['meta'] : ''),
	'bIsStaff' => (App::getUser('type') == '0' ? true : ((App::getUser('type') == '1' && $oSecurity->isStaffAllowed('admin.main.pages')) ? true : false)),
	'iId' => (isset($aCachedPage['page_id']) ? $aCachedPage['page_id'] : ''),
));
?>